<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>行内元素的居中</title>

    <style>
        .box1{
            width: 200px;
            height: 200px;
            background-color: aqua;
            /* 行内元素的水平居中(单行/多行) 将父元素设置 text-align: center属性即可
              对于没有设置宽高的块元素进行水平方向的居中也是这么做，只是要将块元素转化为行内元素
              display:inline
            */
            text-align: center;
            /* 单行元素的垂直居中将父盒子的高度和行高设置一样即可 */
            line-height: 200px;
        }

        .box2{
            width: 300px;
            height: 300px;
            background-color: beige;
            text-align: center;
            
             /* 多行文本的垂直居中的方式*/
            display: table-cell;
            vertical-align: middle;
        }
    </style>
</head>
<body>
    <div class="box1">
        <span>hello world</span>
    </div>

    <div class="box2">
        <span>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eveniet dolorum, perspiciatis nihil iste libero numquam eaque dignissimos quisquam cum alias porro id, explicabo quidem inventore vel, incidunt ad autem nemo.</span>
    </div>
</body>
</html>